<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<meta name="keywords" content="吾知读书，简单便捷的读书工具" />
<meta name="description" content="新建一篇文章并分享到移动设备上阅读" />
<meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0" />
<title>吾知读书-新建文章</title>
<link href="css/common.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="js/jquery-1.6.2.min.js"></script>
<script src="include/ckeditor/ckeditor.js" type="text/javascript"></script>
<style>
body, div, dl, dt, dd, ul, ol, li, h1, h2, h3, h4, h5, h6, pre, code, form, fieldset, legend, input, button, textarea, p, blockquote, th, td{margin:0;padding:0;}
html{-webkit-text-size-adjust:none;}
#page_ctn{overflow:hidden;position:relative;font-size:20px;}
#page_ctn.loading .form{display:none;}
#page_ctn.loading .result{display:block;}
h1{height:35px;background:#eee;line-height:35px;font-size:14px;padding-left:10px;color:blue;}
button{width:90px;height:30px;border:1px solid #ccc;color:#333;margin:20px auto;display:block;cursor:pointer;}
</style>
</head>
<body>
<div id="page_ctn">
	<div class="form">
		<h1>新建一篇文章并分享到移动设备上阅读</h1>
		<textarea id="editor1"></textarea>
		<button>生成</button>
	</div>
</div>

<script type="text/javascript" src="js/YY_dialog.js"></script>
<script type="text/javascript" src="js/common.js"></script>
<script type="text/javascript">
var w_w=$(window).width()-5,w_h=$(window).height()-30;
$('#page_ctn').css({width:w_w+5+'px',height:w_h+30+'px'});
var oCKeditor = CKEDITOR.replace( 'editor1',{ height: w_h-120 });
//oCKeditor.on( 'instanceReady', function( event )
//		{
//			var editor = event.editor;
//			setTimeout( function()
//			{
//				// Delay bit more if editor is still not ready.
//				if ( !editor.element )
//				{
//					setTimeout( arguments.callee, 100 );
//					return;
//				}
//				event.removeListener( 'instanceReady', this.callee );
//				if ( editor.name == 'editor1' )
//				{
//					editor.resize(w_w,w_h-80);
//				}
//			}, 0 );
//		}, null, null, 9999 );//oCKeditor.resize(w_w,w_h-80);
$('button').click(function(){
	var obj=$(this);
	var content=oCKeditor.document.getBody().getHtml();
	var vali_data=content.replace(/<[^>].*?>/g,"");
	if(vali_data==''){
		show_info('请输入内容输入内容！','notice',5);
		return false;
	}
	show_info('载入中请稍后','loading');
	obj.attr('disabled','disabled');
	$.ajax({
		url:'/ajax_response.php',
		data:'type=add&content='+encodeURIComponent(content),
		dataType:'text',
		type:'post',
		success:function(data){
			close_info();
			obj.removeAttr('disabled');
			if (data=='0'){
				alert('失败');
				$('#page_ctn').removeClass('loading');
			}else{
				alert('成功');
				location.href="read.html?id="+data;
			}
		},
		error:function(){
			obj.removeAttr('disabled');
			show_info('操作失败，请稍后再试！','notice');
		}
	});
});
</script>
</body>
</html>